import React from 'react'

class BackgroundPropertySettingProperty extends React.Component {
  constructor(props) {
    super(props)

    this.state = {
      data: {}
    }
  }

  componentWillReceiveProps(props) {
    this.setState({
      data: props.data
    })
  }

  onDataSubmit() {
    // var keyWord = $(this.refs.messageKeyWord).val(),
    //     id = $(this.refs.messageId).val() || (new Date().getTime());
    // var data = {
    //   id: id,
    //   keyWord: keyWord
    // }
    if (this.props.isEdit) {
      this.props.onDataUpdate(data)
    }else {
      this.props.onDataCreate(data)
    }
  }

  onChange(event, key) {
    var value = $(event.target).val();
    var data = this.state.data;
    data[key] = value;
    this.setState({
      data: data
    })
  }

  onPropertySlected(propertyName){
    $('#bakckgound-propertyId').attr("value",propertyName);
   }

  render() {
    var self = this;
    return (
      <div className="modal fade" id="DemoSettingEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div className="modal-dialog" role="document">
          <div className="modal-content">
            <div className="modal-header">
              <button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 className="modal-title" id="demo-modal-label">选择小区物业</h4>
            </div>
            <div className="modal-body">
              <div className="form-group">
                {// <input ref="messageKeyWord" type="text" className="form-control"
                //         id="message-keyWord" placeholder="" value={self.state.data.keyWord}
                //         onChange={(event)=>this.onChange(event, "keyWord")}/>
              }
                <div className="message-eventkey-list">
                  <table className="table table-bordered">
                    <tbody>
                      <tr >
                        <td data-dismiss="modal" onClick={(event)=> this.onPropertySlected("物业1")}><input name="Property" type="radio" value="" />&nbsp;&nbsp;物业1 </td>
                      </tr>
                      <tr >
                        <td data-dismiss="modal" onClick={(event)=> this.onPropertySlected("物业2")}><input name="Property" type="radio" value="" />&nbsp;&nbsp;物业2 </td>
                      </tr>
                      <tr >
                        <td data-dismiss="modal" onClick={(event)=> this.onPropertySlected("物业3")}><input name="Property" type="radio" value="" />&nbsp;&nbsp;物业3 </td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>
              <input ref="demoId" value={self.props.data.id} hidden/>

            </div>

          </div>
        </div>
      </div>
    )
  }
}

export default BackgroundPropertySettingProperty
